HTMLify

style.css
Views: 29 | Author: cody
@import url('https://fonts.googleapis.com/css?family=Fira+Mono:700');

body {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  background-color: #0050b7;
}

fieldset {
  border: none;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: 100%;
  height: 55px;
  width: fit-content;
  background-color: rgba(0, 0, 0, 0.35);
  padding: 6px;
  border-radius: 10px;
  gap: 4px;
  --active: 0;
}

fieldset:has(label:nth-child(2) input:checked) {
  --active: 1;
}

fieldset:has(label:nth-child(3) input:checked) {
  --active: 2;
}

fieldset .selector {
  grid-area: 1/1/2/2;
  height: 100%;
  width: 100%;
  border-radius: 6px;
  position: relative;
  pointer-events: none;
}

fieldset .selector::before,
fieldset .selector::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #fff;
  border-radius: inherit;
  transform: translateX(calc(var(--active) * (100% + 4px)));
  transition: 0.4s transform cubic-bezier(0.28, 1.33, 0.64, 1);
}

fieldset .selector::before {
  transition-delay: 0.05s;
}

label {
  position: relative;
  z-index: 1;
  cursor: pointer;
}

label:nth-child(1) {
  grid-area: 1/1/2/2;
}

label:nth-child(2) {
  grid-area: 1/2/2/3;
}

label:nth-child(3) {
  grid-area: 1/3/2/4;
}

label input {
  position: absolute;
  opacity: 0;
  height: 0;
  width: 0;
}

label input:checked~span {
  color: #000;
  opacity: 1;
}

label input:not(:checked):hover~span {
  opacity: 1;
}

label span {
  padding: 0 20px;
  height: 100%;
  border-radius: 4px;
  color: #fff;
  opacity: 0.6;
  font: 700 15px/1 'Fira Mono';
  text-transform: uppercase;
  text-align: center;
  display: grid;
  place-items: center;
  transition: 0.1s opacity ease-in-out, 0.1s color ease-in-out;
}

Comments